package org.clipjoint.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 	字符编码过滤器
 * @author
 * date: 2021-1-12	
 *
 */
@WebFilter("/*")
public class CharSetFilter implements Filter {

	public void destroy() {
	}

	// 设置请求和响应的字符编码
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		chain.doFilter(request, response);
	}

	public void init(FilterConfig fConfig) throws ServletException {
	}

}
